<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*" %>
<%@ page import="org.swim.entity.User" %>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Search by Name</title>
	<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
	<%@ include file="NavBar.jsp" %>
	<div class="container">
	<% 
	if (session.getAttribute("status").equals("guest")) { %>
	<%@ include file="NoRights.jsp" %>		
	<% } else { %>
	<div class="row">
	<h1>Search by Name</h1>	
	<form action="Search" method="post" class="navbar-search pull-left">
		<p>Insert here the name you want to search 
  		<input type="text" name="searchName" class="search-query" placeholder="Search">
    	<input type="hidden" name="param" value="name">
  		<button type="submit" class="btn">Search</button></p>
	</form>
	</div>	
		<% 
		try {
			ArrayList<User> results = (ArrayList<User>) request.getAttribute("searchResults");	
		
		for(User u:results) {%>
			<div class="row">
				<div class="media"><a class="pull-left" href="<% out.print("Profile?id="+ u.getId());%>">
				<img class="media-object" alt="64x64" style="width: 64px; height: 64px;" src="<% out.print(u.getAvatar()); %>" data-src="holder.js/64x64">
				<div class="media-body">		
			    <h4 class="media-heading"><% out.print(u.getNome() + " " + u.getCognome()); %></h4></div></a></div>
		    </div>
		<% } 
		} catch (NullPointerException e) { } %> 
	<% } %>
	</div>
</body>
</html>